package com.power.controller.DefectAd;

import com.alibaba.fastjson.JSONObject;
import com.power.ov.ResultDataTable;
import com.power.service.DefectAdService;
import com.power.service.impl.defectAdServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * Created/**
 * Created with IntelliJ IDEA.
 * User: lh
 * Date: 2020/10/04 10:57
 * Description:
 * Version: V1.0
 */
@WebServlet("/querySolveTask.do")
public class querySolveTask extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1、当前页码数
        int currentPage = Integer.parseInt(request.getParameter("page"));
        //2、每页显示的条数
        int pageSize = Integer.parseInt(request.getParameter("limit"));
        System.out.println(pageSize);
        DefectAdService defectAdService=new defectAdServiceImpl();


        ResultDataTable resultDataTable = null;
        try {
            resultDataTable = defectAdService.querySolveTask(currentPage,pageSize);
            //将对象封装成JSON数据返回
            response.setContentType("application/json;charset=utf-8");
            response.getWriter().write(JSONObject.toJSONString(resultDataTable));
            response.getWriter().flush();
            response.getWriter().close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
